package rmi;

import gui.Choix;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;

import client.Client;

public class RmiInterfaceImp extends UnicastRemoteObject implements RmiInterface {

	private int id;
	private  Groupe gp;
	private ArrayList<Message> listMsg;
	private static final long serialVersionUID = 1L;
	private String pro;
	
	public  RmiInterfaceImp(Groupe group) throws RemoteException {
		super();
		this.gp = group;
		this.listMsg = new ArrayList<Message>();
		getTypePro();		
	}
	
	public void getTypePro(){
		Choix c=new Choix();
		int choix=c.getchiox();
		c.dispose();
		gp.setProtocole(choix);
		
	}
	
	public String getPro(){
		return pro;
	}
	
	public int enregistreClient(Client cl) throws RemoteException 
    {	
    	System.out.println("Un nouveau client s'connecte...");
    	id = this.gp.enregistreClient(cl);
    	return id;
    }
    
	public ArrayList<Message> recvMsg() throws RemoteException 
    {
		if(this.gp.recvMsg().size()!=0)
			listMsg = this.gp.recvMsg();
		return listMsg;
    }
	
    public void recvLog(int[] list, Message msg) throws RemoteException 
    {
    	this.gp.recvLog(list,msg);
    }
    
    public void envMsg(Message msg,int flag) throws RemoteException 
    {
    	this.gp.envMsg(msg,flag);
    }
    

}
